<?php
namespace ImiDemo\HttpDemo\MainServer\Controller;

use Imi\Controller\HttpController;
use Imi\Server\View\Annotation\View;
use Imi\Server\Route\Annotation\Route;
use Imi\Server\Route\Annotation\Action;
use Imi\Server\Route\Annotation\Controller;
use Imi\Process\ProcessManager;

/**
 * Process 演示
 * @Controller("/Process/")
 * @View(renderType="json")
 */
class ProcessController extends HttpController
{
    /**
     * 启动进程并等待结果
     * 访问：http://127.0.0.1:8080/Process/run
     * 
     * @Action
     * @return void
     */
    public function run()
    {
        $result = ProcessManager::run('tp1');
        return [
            'success'    =>    true,
            'result'    =>    $result,
        ];
    }

    /**
     * 启动进程不等待结果
     * 访问：http://127.0.0.1:8080/Process/coRun
     * 
     * @Action
     * @return void
     */
    public function coRun()
    {
        ProcessManager::coRun('tp1');
        return [
            'success'    =>    true,
        ];
    }
}